Skip to content

fix(sdk): first async export after one interval, not two - #3901

Merged
cijothomas merged 1 commit into
open-telemetry:mainfrom
sapnasingh4852-source:fix/3897-async-first-tick
Dec 4, 2026
Merged

cijothomas merged 1 commit into
open-telemetry:mainfrom
sapnasingh4852-source:fix/3897-async-first-tick

Conversation

@sapnasingh4852-source

Copy link
Copy Markdown
Contributor

Fixes #3897

Changes

to_interval_stream sleeps before every tick, including the first (unfold yields only after runtime.delay resolves). The experimental async-runtime PeriodicReader, BatchSpanProcessor and BatchLogProcessor still called .skip(1) on top of it, so their first collection/flush waited two intervals. The thread-based processors export after one interval.

Removed the three .skip(1) calls in metrics/periodic_reader_with_async_runtime.rs, trace/span_processor_with_async_runtime.rs and logs/log_processor_with_async_runtime.rs, and added the regression test first_collection_happens_after_one_interval.

The test uses a fake Runtime whose delay is held until the test releases it: it asserts the worker waits exactly one interval before collecting, then releases only that first tick and asserts a collection happens. With .skip(1) restored the test fails (no collection within 5s); without it, it passes. Full suite: cargo test -p opentelemetry_sdk --all-features --lib -> 514 passed, 25 ignored. cargo fmt --check and cargo clippy -p opentelemetry_sdk --all-targets --all-features -- -Dwarnings are clean.

Merge requirement checklist

  • CONTRIBUTING guidelines followed
  • Unit tests added/updated (if applicable)
  • Appropriate CHANGELOG.md files updated for non-trivial, user-facing changes
  • Changes in public API reviewed (if applicable)

The periodic ticker built by to_interval_stream already delays before
its first tick, so the extra .skip(1) made the first metrics collection
and batch flush wait two intervals. Remove the skip from the async
PeriodicReader, BatchSpanProcessor and BatchLogProcessor so they match
the thread-based processors, and add a regression test that fails if
the skip is restored.
@sapnasingh4852-source
sapnasingh4852-source requested a review from a team as a code owner December 3, 2026 08:34
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Merged · refreshed 2026-12-04 02:12 UTC

Status above doesn't look right?
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Dec 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.95918% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 86.7%. Comparing base (070a73f) to head (c3c1a77).

Files with missing lines Patch % Lines
.../src/metrics/periodic_reader_with_async_runtime.rs 97.9% 1 Missing ⚠️
Additional details and impacted files
@@          Coverage Diff          @@
##            main   #3901   +/-   ##
=====================================
  Coverage   86.7%   86.7%           
=====================================
  Files        131     131           
  Lines      34712   34756   +44     
=====================================
+ Hits       30116   30159   +43     
- Misses      4596    4597    +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cijothomas cijothomas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks good.

(IIRC, I added the skip(1) long ago, but we missed to remove it when the interval imply was changed later)

@cijothomas
cijothomas added this pull request to the merge queue Dec 4, 2026
Merged via the queue into open-telemetry:main with commit 802dc77 Dec 4, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: async-runtime PeriodicReader does its first export after 2x the interval

2 participants